using System;
using System.Text;
using Unity.Type.BinaryType;
using Xunit;

namespace Unity.Type.Tests
{
    public class MetadataSerializerTest
    {
        public static Metadata PrepareMetadataObject()
        {
            Metadata metadata = new Metadata();
            metadata.UnityId = new ReadOnlySpan<byte>(Encoding.ASCII.GetBytes("144347:256234"));
            metadata.Version = 123;
            metadata.ChangerCsiId = 144347;
            metadata.Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
            metadata.EntityType = EntityType.Order;
            metadata.EventType = EventType.Update;
            metadata.FormatVer = 1;
            metadata.VersionDelete = 456;
            return metadata;
        }

        public static byte[] PrepareMetadataSerializedData(Metadata metdataObj)
        {
            MetadataSerializer serializer = new MetadataSerializer();
            return serializer.Serialize(metdataObj);
        }

        [Fact]
        public void MethodsTest()
        {
            Metadata testMetadata = PrepareMetadataObject();
            byte[] serialMetadata = PrepareMetadataSerializedData(testMetadata);
            Assert.True(serialMetadata.Length > 0);
        }

    }
}
